package com.waves.message.controller;

/**
 * @author Eden
 * @date 2025/01/05 20:56
 **/

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.waves.core.web.domain.R;
import com.waves.core.web.domain.TableDataInfo;
import com.waves.message.domain.dto.MessageRecordPageDTO;
import com.waves.message.service.MessageRecordService;
import com.waves.message.vo.MessageRecordPageVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/messageRecord")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@ApiModel("消息中心记录")
public class MessageController {

    private final MessageRecordService messageRecordService;


    @ApiOperation("分页查询消息通知")
    @GetMapping("/page")
    public TableDataInfo<MessageRecordPageVO> page(MessageRecordPageDTO messageRecordPageDTO) {
        return TableDataInfo.build(messageRecordService.pageMessageRecords(messageRecordPageDTO));
    }

    @ApiOperation("获取未读消息数")
    @GetMapping("/getMessageRecordNum")
    public R<Integer> getMessageRecordNum() {
        return R.ok(messageRecordService.getMessageRecordNum());
    }

    @ApiOperation("将通知设置为已读")
    @GetMapping("/setRead/{taskId}/{noticeType}/{messageType}/{taskCommentId}")
    public R<Object> setRead(@PathVariable String taskId,
                             @PathVariable Integer noticeType,
                             @PathVariable Integer messageType,
                             @PathVariable String taskCommentId) {
        return messageRecordService.setRead(taskId,noticeType,messageType,taskCommentId);
    }

}
